from django.contrib import admin
from .models import KnowledgeBase, Tag, Document, DocumentChunk


@admin.register(KnowledgeBase)
class KnowledgeBaseAdmin(admin.ModelAdmin):
    list_display = ['name', 'user', 'is_default', 'created_at']
    list_filter = ['is_default', 'user']
    search_fields = ['name', 'description']


@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
    list_display = ['name', 'user', 'color', 'created_at']
    list_filter = ['user']
    search_fields = ['name']


@admin.register(Document)
class DocumentAdmin(admin.ModelAdmin):
    list_display = ['title', 'user', 'knowledge_base', 'file_type', 'status', 'vector_indexed', 'created_at']
    list_filter = ['file_type', 'status', 'vector_indexed', 'user']
    search_fields = ['title', 'content']
    filter_horizontal = ['tags']
    date_hierarchy = 'created_at'


@admin.register(DocumentChunk)
class DocumentChunkAdmin(admin.ModelAdmin):
    list_display = ['document', 'chunk_index', 'token_count', 'created_at']
    list_filter = ['document']
    search_fields = ['content']
